from functools import wraps

from utils.custom_exceptions import AuthenticationErrorException


def authorize(view_func):
	@wraps(view_func)
	def wrapped_view(request, *args, **kwargs):
		if "user" not in request.session:
			raise AuthenticationErrorException()
		return view_func(request, *args, **kwargs)
	return wrapped_view